home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1119 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to dynamically allocate first element of linked list.
  5. Date: 11 Jan 1996 15:45:37 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan11084537@qcd.lanl.gov>
  8. References: <erkDL007G.rt@netcom.com>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: erk@netcom.com's message of Thu, 11 Jan 1996 00:48:04 GMT
  13.  
  14. --text follows this line--
  15. In article <erkDL007G.rt@netcom.com> erk@netcom.com (Staugher) writes:
  16. <snip>
  17.    struct elmnt * newlist(void)
  18.    {
  19.    struct elmnt *newptr;
  20.    newptr = malloc(sizeof(struct elmnt));
  21.    return (newptr);
  22.    }
  23.  
  24.    //=======================================
  25.  
  26.  
  27.    The compiler complains with an ERROR that it cannot convert
  28.    (void *) to (elmnt *) in function newlist
  29.  
  30. First off, you don't show it, but you probably _have_ included
  31. <stdlib.h>. Please post complete compilable code, NOT fragments.
  32.  
  33. Second, // does NOT introduce a comment in C. It does in C++.
  34.  
  35. Third, the error message is likely to have come from a C++ compiler:
  36. not a C compiler. 
  37.  
  38.    I hope that the problem is obvious to someone :/
  39.  
  40. If you want to compile a C program, use a C compiler. If you have
  41. problems with C++, post in an appropriate newsgroup. C and C++ are not
  42. the same compiler, though small computer (PC/Mac) users often seem to
  43. forget that. 
  44.  
  45. Cheers
  46. Tanmoy
  47. --
  48. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  49. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  50. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  51. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  52. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  53. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  54.